package com.easyar.customizdb;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.easyar.customizdblibrary.CustomizDBFactory;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        List<Friends> list=new ArrayList<>();
        for (int x=0;x<5000;x++){
            list.add(new Friends("yanjin",23));
        }
        long startTime = System.currentTimeMillis();
        //删除
        int delete = CustomizDBFactory.getFactory(MainActivity.this)
                .getDao(Friends.class).delete("name = ? ", new String[]{"haha"});
        //更新
        int update = CustomizDBFactory.getFactory(MainActivity.this)
                .getDao(Friends.class).update(new Friends("hehe",0), "name = ? ", new String[]{"haha"});
        //插入多条
        CustomizDBFactory.getFactory(MainActivity.this).getDao(Friends.class).insert(list);
        //插入多条
        CustomizDBFactory.getFactory(MainActivity.this).getDao(Friends.class).insert(new Friends("haha",23));
        //查询
        List<Friends> query = CustomizDBFactory.getFactory(MainActivity.this).getDao(Friends.class).queryDB().setmSelection("name =? ").setmSelectionArgs(new String[]{"hehe"}).query();
        //查询所有
        List<Friends> query2 = CustomizDBFactory.getFactory(MainActivity.this).getDao(Friends.class).queryDB().queryAll();

        long endTime = System.currentTimeMillis();
        System.out.println("yanjin----time-"+(endTime-startTime)+"--update--"+update+"--delete--"+delete);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
